package utils.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.android.volley.toolbox.NetworkImageView;
import com.lanou.horo.myapplication.R;

import java.util.List;

import entity.LiveMoreEntity;
import entity.LivePageEntity;
import volley.VolleySingleton;

/**
 * Created by dllo on 15/11/24.
 */


        import android.support.v7.widget.RecyclerView;
        import android.view.LayoutInflater;
        import android.view.View;
        import android.view.ViewGroup;
        import android.widget.TextView;

        import com.android.volley.toolbox.NetworkImageView;
        import com.lanou.horo.myapplication.R;

        import java.util.List;

        import entity.LivePageEntity;
        import volley.VolleySingleton;

/**
 * Created by dllo on 15/11/20.
 */
public class LiveMoreAdpter extends
        RecyclerView.Adapter<LiveMoreAdpter.RecyerAdpter> {

    private List<LiveMoreEntity.ResultEntity> result;

    public void addData( List<LiveMoreEntity.ResultEntity> result){
        this.result = result;
        notifyDataSetChanged();
    }

    @Override
    public RecyerAdpter onCreateViewHolder(ViewGroup parent, int viewType) {
        LayoutInflater inflater = LayoutInflater.from(parent.getContext());
        View view = inflater.inflate(R.layout.live_pagr_item,null);

        return new RecyerAdpter(view);
    }

    @Override
    public void onBindViewHolder(RecyerAdpter holder, int position) {
        LiveMoreEntity.ResultEntity radio = result.get(position);
        if (result!=null && result.size() > 0 ){
            holder.contentTvOne.setText(radio.getRadioPlayCount()+"");
            holder.fm_now_one.setText(radio.getProgramName());
            holder.fm_name_one.setText(radio.getRname());
            VolleySingleton.getInstance().getBitmap(radio.getRadioCoverSmall(),holder.live_pOne_IV);

        }

    }

    @Override
    public int getItemCount() {
        return result!=null && result.size() > 0 ? result.size() :0;
    }

    class RecyerAdpter extends RecyclerView.ViewHolder implements View.OnClickListener {
        private TextView fm_name_one,fm_now_one,contentTvOne;
        private NetworkImageView live_pOne_IV;
        private ImageView radioPlayUrl;

        public RecyerAdpter(View itemView) {
            super(itemView);
            fm_name_one = (TextView) itemView.findViewById(R.id.fm_name_one);
            fm_now_one = (TextView) itemView.findViewById(R.id.fm_now_one);
            contentTvOne= (TextView) itemView.findViewById(R.id.contentTvOne);
            live_pOne_IV = (NetworkImageView) itemView.findViewById(R.id.live_pOne_IV);
            radioPlayUrl = (ImageView) itemView.findViewById(R.id.radioPlayUrl);
            radioPlayUrl.setOnClickListener(this);
        }

        @Override
        public void onClick(View v) {
            switch (v.getId()){
                case R.id.radioPlayUrl:

                break;

            }
        }
    }
}
